
		// 构造链表节点类型
		function Node(data, next) {
			this.data = data || 'head'
			this.next = next || null
		}

		// 初始化链表
		function InitList () {
			this.head = new Node()
			this.length = 0
			this.currentNode = ''

			// 链表的多个基础操作方法
			this.__proto__.createList = createList
			this.__proto__.getListLength = getListLength
			this.__proto__.insertElem = insertElem
			this.__proto__.appendElem = appendElem
			this.__proto__.locateElem = locateElem
			this.__proto__.findLastElem = findLastElem
			this.__proto__.updateElem = updateElem
			this.__proto__.deleteElem = deleteElem
			this.__proto__.countElems = countElems
			this.__proto__.isEmpty = isEmpty
			this.__proto__.displayElems = displayElems
		}

		// 创建链表
		function createList(array) {

			if ( array.length == 0) {
				console.log('初始化链表参数为空');
				return null
			}

			for ( let i = 0; i < array.length; i++ ) {
				this.appendElem(array[i])
				this.length++
			}

			return this.head
		}

		// 链表的各种操作
		// 1. 获取链表的长度
		function getListLength() {
			return this.length
		}

		// 2. 在链表的某个位置插入新节点
		function insertElem(location, elem) {
			
		}

			// 尾插法
		function appendElem(elem) {

			let cur = this.findLastElem()
			let newNode = new Node(elem)
			
			cur.next = newNode
			newNode.next = null

			return cur
		}

		// 3. 获取链表某个位置的元素
		function locateElem(elem) {
			let cur = this.head

			while (cur && cur.data != elem) {
				cur = cur.next
			}

			if (!cur) {
				console.log('未找到指定元素');
				return -1
			}

			return cur
		}

		// 获取最后一个元素
		function findLastElem () {
			let cur = this.head
			while (cur.next) {
				cur = cur.next
			}

			return cur
		}

		// 4. 修改链表指定位置的元素
		function updateElem(location, data) {
			
		}

		// 5. 删除链表指定节点元素
		function deleteElem(elem, signal) {

			let cur = this.head

			if (!this.locateElem(elem)) {
				console.log('错误！指定节点不存在。');
				return
			}

			if ('head' == elem && !arguments[1]) {
				console.log('指定节点为头结点，若要继续执行则整个链表将被删除，请重新执行方法且另需参数1确认删除');

			if ('head' == elem && signal == 1) {
				while (cur.next.data !== elem) {
					cur = cur.next
				}

				cur.next = cur.next.next
				this.length --
			}
				return
			}
		}

		// 6. 统计链表元素个数
		function countElems(list) {}

		// 7. 链表判空
		function isEmpty() {
			return this.head.next == null
			// return this.length === 0
		}

		// 8. 遍历访问链表的各个元素
		function displayElems() {
			let list = ''
			let p = this.head
			while ( p ) {
				list += p.data
				p = p.next
				if (p) {
					list += ' -> '
				}
			}
			console.log(list);
			return list
		}
